package com.sky.controller.admin;


import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.result.Result;
import com.sky.service.ISetmealService;
import com.sky.vo.SetmealPageVO;
import com.sky.vo.SetmealVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 套餐 前端控制器
 * </p>
 *
 * @author xieminghui
 * @since 2023-11-16
 */
@RestController
@RequestMapping("/admin/setmeal")
public class SetmealController {

    @Resource
    private ISetmealService setmealService;

    /**
     *  套餐分页查询
     * @author: XieMingHui
     * @date: 23/11/20 14:21:13
     * @param: [套餐名称,套餐分类,状态]
     * @return: com.sky.result.Result<java.lang.String>
     **/
    @GetMapping("/page")
    public Result<SetmealPageVO> findPage(SetmealPageQueryDTO setmealPageQueryDTO){
       return setmealService.findPage(setmealPageQueryDTO);
    }
    /**
     * 新增套餐
     * @author: XieMingHui
     * @date: 23/11/20 21:03:52
     * @param: [setmealDTO]
     * @return: com.sky.result.Result<java.lang.String>
     **/
    @PostMapping
    public Result<String> saveSetmeal(@RequestBody SetmealDTO setmealDTO){
        return setmealService.saveSetmeal(setmealDTO);
    }
    /**
     * 根据id查询套餐详情,用于修改回显
     * @author: XieMingHui
     * @date: 23/11/20 19:00:00
     * @param: [id]
     * @return: 套餐详情,包含菜品信息
     **/
    @GetMapping("/{id}")
    public Result<SetmealVO> findById(@PathVariable Long id){
        return setmealService.findById(id);
    }
    /**
     * 修改套餐
     * @author: XieMingHui
     * @date: 23/11/20 19:00:00
     * @param: [id]
     * @return: 套餐详情,包含菜品信息
     **/
    @PutMapping
    public Result<String> update(@RequestBody SetmealDTO setmealDTO){
        return setmealService.updateSetmeal(setmealDTO);
    }
    /**
     * 修改售卖状态
     * @author: XieMingHui
     * @date: 23/11/20 19:00:00
     * @param: [status,id]
     * @return: 操作结果
     **/
    @PostMapping("/status/{status}")
    public Result<String> updateStatus(@PathVariable Integer status ,@RequestParam Long id){
        return setmealService.updateStatus(status,id);
    }
    /**
     * 删除套餐
     * @author: XieMingHui
     * @date: 23/11/20 19:00:00
     * @param: [id]
     * @return: 操作结果
     **/
    @DeleteMapping
    public Result<String> DeleteStatus(@RequestParam List<Long> ids){
        return setmealService.DeleteStatus(ids);
    }
}
